﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.ComponentModel;
using BaseTypesLib.Model.Fonts;
using System.Windows.Forms.Design;

namespace BaseTypesLib.UiTypeEditors
{
    public class FontEditor:UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.DropDown;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            if (service == null)
            {
                return base.EditValue(context, provider, value);
            }

            FontControl ctrl = new FontControl((Font)value);

            service.DropDownControl(ctrl);
            Font res = ctrl.GetFont();
            return res;
        }
    }
}
